package com.tl.listener;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.tl.util.UpdateDataTask;

/**
 * Application Lifecycle Listener implementation class UpdateDataListener
 *
 */
public class UpdateDataListener implements ServletContextListener {

	private Timer timer;
    public UpdateDataListener() {
    	
    }

    public void contextInitialized(ServletContextEvent arg0) {
    	timer = new Timer();
    	timer.schedule(new UpdateDataTask(), 1000*60, 24*60*60*1000);   // 一分钟后开始执行,每天一次
    }

    public void contextDestroyed(ServletContextEvent arg0) {
    	//销毁定时器
    	timer.cancel();
    }
	
}
